﻿using JNPF.Common.Security;
using JNPF.Common.Models;
using JNPF.Website.Entitys.Dto.WebsiteProduct;
using Mapster;

namespace JNPF.Website.Entitys.Mapper.WebsiteProduct;

public class Mapper : IRegister
{
	public void Register(TypeAdapterConfig config)
	{
		config.ForType<WebsiteProductCrInput, WebsiteProductEntity>()
			.Map(dest => dest.MainImage, src => src.mainImage.ToJsonString())
			.Map(dest => dest.VideoUrl, src => src.videoUrl.ToJsonString())
		;
		config.ForType<WebsiteProductEntity, WebsiteProductInfoOutput>()
			.Map(dest => dest.mainImage, src => src.MainImage.ToObject<List<FileControlsModel>>())
			.Map(dest => dest.videoUrl, src => src.VideoUrl.ToObject<List<FileControlsModel>>())
		;
	}
}
